/******************************************************************************
copyright(c)cguage.com
source code can be free to use and publish, but please keep header comments, thx

author:  cguage
contact: tangcraig@gmail.com
desc:    missing
date:    unknown

*******************************************************************************/
#pragma once
#include <thread>
#include <string>
#include "WndEventBinding.h"
#include "Timer.h"

extern std::string loadResString(int id);

class InfoWnd
{
    InfoWnd();      
    ~InfoWnd(); // delete not allowed, use WM_DESTROY insteed

public:
    static bool     create(HINSTANCE hinst);
    static InfoWnd* instance() {return m_instance;}

    void            blink();
    void            showText(const std::string& text);

protected:
    bool            init(HINSTANCE hinst);
    HWND            createWnd(HINSTANCE hinst);
    static LRESULT CALLBACK wndMsgProc(HWND, UINT, WPARAM, LPARAM);
    void            wndMsgPump();

    DECLARE_MSG_MAP
    LRESULT         onWndInit(WPARAM, LPARAM);
    LRESULT         onCtrlColor(WPARAM, LPARAM);
    LRESULT         onPaint(WPARAM, LPARAM);
    LRESULT         onDestroy(WPARAM, LPARAM);
    LRESULT         onUpdateInfo(WPARAM, LPARAM);

private:
    static InfoWnd*         m_instance;
    static std::thread      m_msgThread;
    static std::map<HWND, InfoWnd*> m_hwnd2Obj;
    HWND                    m_hwnd;
    bool                    m_blink;
    CggUtil::Timer          m_timer;
};